<template>
	<div class="comment-info" v-if="commentInfo !== null && commentInfo.images !== null">
		
		<div class="header-info">
			<div class="header-title">用户评价</div>
			<div class="header-more">更多</div>
		</div>
		
		<div class="user-info">
			<img :src="commentInfo.user.avatar"/>
			<span>{{commentInfo.user.uname}}</span>
		</div>
		
		<div class="detail-info">
			<p>{{commentInfo.content}}</p>
			<div class="other-info">
				<span class="data">{{date}}</span>
				<span>{{commentInfo.style}}</span>
			</div>
		</div>
		
		<div class="imgs-info">
			<img :src="item" 
					 v-for="(item, index) in commentInfo.images" 
					 :key="index">
		</div>
	</div>
</template>

<script>
	import {formatDate} from 'common/utils.js'
	export default{
		name:'CommentInfo',
		props:{
			commentInfo: {
				type:Object,
				default(){
					return {}
				}
			}
		},
		computed: {
			date(){
				//1.将时间戳转成Date对象
				const date = new Date(this.commentInfo.created * 1000)
				
				//2.将date进行格式化
				return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
			}
		}
	}
</script>

<style scoped="scoped">
	.comment-info{
		padding: 5px 12px;
		color: #333;
		border-bottom: 5px solid #F2F5F8;
	}
	.header-info{
		height: 50px;
		line-height: 50px;
		border-bottom: 1px solid rgba(0,0,0,.1);
	}
	.header-title{
		float: left;		
		font-size: 15px;
	}
	.header-more{
		float: right;
		margin-right: 10px;
		font-size: 13px;
	}
	.user-info{
		padding: 10px 0 5px;
	}
	.user-info img{
		width: 42px;
		height: 42px;
		border-radius: 50px;
	}
	.user-info span{
		position: relative;
		top: -15px;
		font-size: 15px;
		margin-left: 10px;
	}
	.detail-info{
		padding: 0 5px 15px;
	}
	.detail-info p{
		font-size: 14px;
		color: #777;
		line-height: 1.5;
	}
	.detail-info .other-info{
		font-size: 12px;
		color: #999;
		margin-top: 10px;
	}
	.detail-info .data{
		margin-right: 8px;
	}
	.imgs-info img{
		width: 70px;
		height: 70px;
		margin-right: 5px;
	}
</style>
